/*
 * Copyright (c) 2021. Moses All Right Reserved
 */

package com.moses.design_patterns.proxy.static_proxy.abstract_proxy;

/**
 * @author Moses
 * @email shenhuohui@gmail.com
 * @date 2021/4/10 18:00
 */

/**
 * 继承同一个父类，目标类能做的，代理也能做
 */
public class Proxy extends AbstractSubject {

    AbstractSubject subject = null;

    private  void before(){
        System.out.println("事前处理");
    }

    private void after(){
        System.out.println("事后处理");
    }

    public Proxy(AbstractSubject realSuject){
        this.subject = realSuject;
    }

    @Override
    public void method() {
        // 代理可以做一些事前事后处理
        before();
        subject.method();
        after();
    }
}
